﻿using ICSharpCode.TextEditor;
using ICSharpCode.TextEditor.Document;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CodeGenerator.UI
{
    /// <summary>
    /// 代码显示器
    /// </summary>
    public sealed class FormatCodeHelper
    {
        public static string CSHARP = "C#";

        public static string TSQL = "TSQL";

        public static string VBNET = "VBNET";

        public static string ASPNET = "ASP3/XHTML";

        public static string XML = "XML";

        public static string HTML = "HTML";

        public static string TEXT = "TeX";

        public static string CPPNet = "C++.NET";

        public static string JAVA = "Java";

        public static string JAVASCRIPT = "JavaScript";

        public static string PHP = "PHP";

        public static string BAT = "BAT";

        public static string BOO = "Boo";

        public static string COCO = "Coco";

        public static string[] CodeFormatType = new string[]
		{
			"ASP3/XHTML",
			"BAT",
			"Boo",
			"Coco",
			"C++.NET",
			"C#",
			"HTML",
			"Java",
			"JavaScript",
			"PHP",
			"TeX",
			"VBNET",
			"XML",
			"TSQL"
		};

        public static void FormatText(TextEditorControl editor, string type, string text)
        {
            editor.ShowEOLMarkers = false;
            editor.ShowInvalidLines = false;
            editor.ShowSpaces = false;
            editor.ShowTabs = false;
            editor.Document.HighlightingStrategy = HighlightingStrategyFactory.CreateHighlightingStrategy(type);
            editor.Encoding = System.Text.Encoding.Default;
            editor.Text = text;
        }
    }
}
